#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QLabel>
#include <QMouseEvent>
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkReply>
#include "weatherdata.h"


QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:

    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();


protected:
    void contextMenuEvent(QContextMenuEvent * event);
    void mousePressEvent(QMouseEvent * event);
    void mouseMoveEvent(QMouseEvent * event);

    void getWeatherInfo(QString cityCode);
    void parseJson(QByteArray& byteArray);
    void updateUI();

    //重写父类的eventfilter方法
    bool eventFilter(QObject* watched, QEvent* event);
    //绘制高低温曲线
    void paintHighCurve();
    void paintLowCurve();

private slots:
    void on_btnSearch_clicked();

private:
    void onReplied(QNetworkReply * reply);
    Ui::MainWindow *ui;

    QMenu *mMenu;
    QAction* mExitAct;
    QAction* mRefreshAct;
    QPoint mOffset; //窗口移动时，和左上角的偏移量

    QNetworkAccessManager *mNetAccessManager;

    Today mToday; //今天的数据
    Day mDay[6]; //六天的数据

    QList<QLabel*> mWeekList;
    QList<QLabel*> mDateList;


    //天气和天气图标
    QList<QLabel*> mTypeList;
    QList<QLabel*> mTypeIconList;

    //天气污染指数
    QList<QLabel*> mAqiList;

    //风力和风向
    QList<QLabel*> mFxList;
    QList<QLabel*> mFlList;

    QMap<QString, QString> mTypeMap;
};
#endif // MAINWINDOW_H
